chore(deploy): cap Docker container logs and enable infra deploys#52
Merged
Conversation
Docker used the default json-file driver with no rotation, so container logs grew unbounded and filled the VDS disk (an 11GB single log file). - deploy.playbook.yml: write /etc/docker/daemon.json with json-file max-size=10m/max-file=3 (global cap), restart docker via handler + flush_handlers before containers start. - feedforbot.compose.yml.j2: explicit logging: block on both services (defense-in-depth, self-documenting). - deploy.yml: trigger deploy on any tmfeed/** change and add workflow_dispatch (optional image_tag), so infra-only changes ship via CI instead of only on release/config.yml pushes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Проблема
На VDS с ботом закончилось место:
/был забит на 100 %. Причина — Docker пишет логи драйверомjson-fileбез ротации, а на сервере нет ни/etc/docker/daemon.json, ниlogging:в compose. За ~3 месяца лог одного контейнера раздулся до 11 GB (плюс лог самого feedforbot — 352 MB).Экстренная разгрузка диска и host-харденинг (fail2ban, отключение парольного SSH, лимит journald) уже сделаны на сервере напрямую. Этот PR закрывает инфраструктурную часть, связанную с ботом, чтобы проблема не повторилась.
Что меняется
tmfeed/deploy.playbook.yml— разворачивает/etc/docker/daemon.jsonсjson-file/max-size=10m/max-file=3(глобальный лимит на контейнер, покрывает и соседние стеки). Рестарт docker через handler +flush_handlersдо запуска контейнеров; идемпотентно (рестарт только при изменении файла).tmfeed/feedforbot.compose.yml.j2— явный блокlogging:с теми же лимитами на обоих сервисах (redis,feedforbot) — defense-in-depth и самодокументирование..github/workflows/deploy.yml— деплой теперь триггерится на любые измененияtmfeed/**(раньше — толькоfeedforbot.config.yml) плюс добавленworkflow_dispatch(с опциональнымimage_tag), чтобы инфра-правки катились через CI, а не только на release.Важное следствие
Деплой по push тянет
ghcr.io/shpaker/feedforbot:latest(сейчас 5.1.0), а на сервере крутится4.0.0rc7→ этот деплой заодно обновит feedforbot до 5.1.0 (согласовано).--force-recreate, так что стек feedforbot подхватит их при этом деплое.Проверка
mypy/ruffне затрагиваются (только YAML);ansible-playbook --syntax-check— OK.deployзелёный; на сервереdocker inspect feedforbot --format '{{.HostConfig.LogConfig}}'→max-size:10m max-file:3; feedforbothealthy, версия 5.1.0, посты идут в@tmfeed.